object Bubble {
	def main() : Unit = {
	println(new BubbleSort().process());	
	}
}

class BubbleSort {
	var table : Int [];
	
	def init(): Int = {
	var i : Int;
	table=new Int [10];
	i=0;	
	  while ( i < table.length ) {
	  	table[i]=10-i;
	  	i=i+1;
	  }
	  return 0;
	}
	def print(): Int = {
	  var i : Int;
	  var s: String;
	  s="";
	  i=0;
	  while(i < table.length){
	  	//println(table[i]);
		s=s+table[i]+" ";
		i=i+1;
	  }
	  println(s);
	  return 0;
	  
	}
	def process():String ={
		var useless: Int;
		useless=this.init();
		useless=this.print();
		useless=this.sort();
		//useless=this.print();
		return "done";
	}
	def sort(): Int ={
	var permut: Bool;
	var i:Int;
	var temp:Int;
	var llength:Int;
	permut=true;

	llength=table.length;
	while(permut){
	    permut=false;
	    i=0;
	    while(i<llength-1){
	    	if(!(table[i]<table[i+1]) && !(table[i]==table[i+1])){
			temp=table[i];
			table[i]=table[i+1];
			table[i+1]=temp;
			permut=true;
	    	
	    	}
		temp=this.print();
		i=i+1;
	    }
	  llength=llength-1;
	}
	return 0;
	}
}
